<?php
include('VerifySession.php');
?>
<?php
include("Header.php");
include("SNManager.class.php");
$db = new SNDataManager();
$txtOldpass= $_REQUEST["txtOldPass"];
$txtNewpass= $_REQUEST["txtNewPasswords"];
$txtRepass= $_REQUEST["txtReNewPasswords"];
$result = false;
if($txtOldpass !='' && $txtNewpass !='' & $txtRepass !=''){
  $result= $db->ChangePasswords($_SESSION["AccountID"],$txtOldpass,$txtNewpass);
  if($result)
  {
        echo "<script type='text/javascript'>alert('Change passwords Success.');</script>";
        $db->redirect("SearchSNPage.php");
            //header( 'Location:SearchSNPage.php' );
  }else
  {
    echo "<script type='text/javascript'>alert('Change passwords Failed.');</script>";
  }
}
    
?>
<script>
function checkForm(frm)
{
	if (frm.txtOldPass.value == "" || frm.txtNewPasswords.value=="" || frm.txtReNewPasswords.value == "")
	{
         alert("Please complete all of the form");
         return false;
     }else if( frm.txtNewPasswords.value != frm.txtReNewPasswords.value)
     {
     	    alert("Passwords and Re type passwords don't miss match");
         	return false;
     }
}
</script>

            <!-- Article -->
             <div id="adbox" align="center">
                <h2>Change Passwords</h2>

                <form id="form1" method="post" action="" onsubmit="return checkForm(this)" >
                  <table width="400" border="0" align="center">
                    <tr>
                      <td width="200" align="right"><div align="right">Old Passwords</div></td>
                      <td align="left"><input type="text" name="txtOldPass" id="txtOldPass" type="password" /></td>
                    </tr>
                    <tr>
                      <td width="200" align="right"><div align="right">New Passwords</div></td>
                      <td align="left"> <input type="text" name="txtNewPasswords" id="txtNewPasswords" type="password" /></td>
                    </tr>
                    <tr>
                      <td width="200" align="right"><div align="right">Re type New Passwords</div></td> 
                      <td align="left">  <input type="text" name="txtReNewPasswords" id="txtReNewPasswords"  type="password" /></td>
                    </tr>
                     <tr>
                      <td width="200" align="right">&nbsp;</td>
                      <td align="left"><input type="submit" name="btnSubmit" id="btnSubmit" value="Save"   class="btnExample"/>
  &nbsp;&nbsp;
  <input type="reset"  value="Cancel"  onclick="location.href = 'index.php';"  /></td>
                    </tr>
                  </table>
              </form>
                <p>&nbsp;</p>
            </div> <!-- /article -->

  <?php
  include("Footer.php");
  ?>
